<?php $gmap_path=Yii::app()->request->baseUrl . '/js/jquery/gmap3.js'; ?>
<html>
    <head>     
        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl . '/js/jquery/gmap3.js' ?>"></script>
        <script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript" ></script>
        <script type="text/javascript">
          function loadMap() {
              var marker= {
                  "lat":"10.801902",
                  "lng":"106.604155"
              }; 
              $('#map').gmap3({
                  map:{
                      options:{
                          center:[10.801902, 106.604155],
                          zoom: 15
                      }
                  },
                  marker:{
                      values: [
                                {latLng:[10.801902, 106.604155], data:"HCM city !"},
                              ],
                      options:{
                          draggable: false
                      },
                      events:{
                          mouseover: function(marker, event, context){
                              var html ='<span><h4><b><font style="color:#0066CC;">Công ty TNHH NHỰT SAGO</font></b></h4></span>';
                              var map = $(this).gmap3("get"),
                              infowindow = $(this).gmap3({
                                  get:{
                                      name:"infowindow"
                                  }
                              });
                              //var html = '<a href="'+path_kards+'/'+context.data.kardId+'"><img src="'+context.data.imageSmall+'"> <span>'+context.data.name+'</span></a>';
                              //html += '<br><span><a href="'+path_audience_kard_trade+'/'+context.data.kardId+'">Number kard Traded:'+context.data.numberKardTraded+'</a></span>';
                              if (infowindow){
                                  infowindow.open(map, marker);
                                  infowindow.setContent(html);
                              } else {
                                  $(this).gmap3({
                                      infowindow:{
                                          anchor:marker, 
                                          options:{
                                              content: html
                                          }
                                      }
                                  });
                              }
                          },
                          mouseout: function(){
                            var infowindow = $(this).gmap3({get:{name:"infowindow"}});
                            if (infowindow){
                              infowindow.close();
                            }
                          }
                          
                      }
                  }
              });
          }
        </script>
        <?php
        $cs = Yii::app()->getClientScript();
        $baseUrl = Yii::app()->request->baseUrl;
        $cs->registerCssFile($baseUrl . '/css/contact.css');
        $cs->registerCssFile($baseUrl . '/css/contact-form.css');
        ?>
        <style type="text/css">
            #map{
                text-align:center;
                width:500px;
                height:500px;
                margin-left:8%;
                margin-top:20px;
                margin-bottom:50px;
                padding-left:10px;
                padding-right:10px;
                position:relative;
                border:1px solid #dfdfdf;
                border-radius:6px;
            }
        </style>
    </head>
    <body  onload="loadMap()">
        <div id="body_main">
            <div id="map">
            </div>
            <div id="contact">
                <h2><?php echo Yii::t('contact', 'contactUs'); ?></h2>

                <?php if (Yii::app()->user->hasFlash('contact')): ?>
                    <div class="flash-success" style="padding-top: 10px;padding-bottom: 10px;">
                        <?php echo Yii::app()->user->getFlash('contact'); ?>
                    </div>
                <?php else: ?>
                    <p>
                        <?php echo Yii::t('contact', 'quote'); ?>
                    </p>
                    <div class="form">
                        <?php
                        $form = $this->beginWidget('CActiveForm', array(
                            'id' => 'contact-form',
                            'enableClientValidation' => true,
                            'clientOptions' => array(
                                'validateOnSubmit' => true,
                            ),
                                ));
                        ?>
                        <p class="note"><?php echo Yii::t('contact', 'fieldsWith'); ?> <span class="required">*</span> <?php echo Yii::t('contact', 'areRequired'); ?>.</p>

                        <?php echo $form->errorSummary($model); ?>

                        <div class="row">
                            <?php echo $form->labelEx($model, 'name'); ?>
                            <?php echo $form->textField($model, 'name'); ?>
                            <?php echo $form->error($model, 'name'); ?>
                        </div>

                        <div class="row">
                            <?php echo $form->labelEx($model, 'email'); ?>
                            <?php echo $form->textField($model, 'email'); ?>
                            <?php echo $form->error($model, 'email'); ?>
                        </div>

                        <div class="row">
                            <?php echo $form->labelEx($model, 'subject'); ?>
                            <?php echo $form->textField($model, 'subject', array('size' => 60, 'maxlength' => 128)); ?>
                            <?php echo $form->error($model, 'subject'); ?>
                        </div>

                        <div class="row">
                            <?php echo $form->labelEx($model, 'body'); ?>
                            <?php echo $form->textArea($model, 'body', array('rows' => 6, 'cols' => 50)); ?>
                            <?php echo $form->error($model, 'body'); ?>
                        </div>

                        <?php if (CCaptcha::checkRequirements()): ?>
                            <div class="row">
                                <?php echo $form->labelEx($model, 'verifyCode'); ?>
                                <div>
                                    <?php $this->widget('CCaptcha'); ?>
                                    <?php echo $form->textField($model, 'verifyCode'); ?>
                                </div>
                                <div class="hint"><?php echo Yii::t('contact', 'verifyCodeHelp1'); ?>
                                    <br/><?php echo Yii::t('contact', 'verifyCodeHelp2'); ?></div>
                                <?php echo $form->error($model, 'verifyCode'); ?>
                            </div>
                        <?php endif; ?>

                        <div class="row buttons">
                            <?php echo CHtml::submitButton(Yii::t('contact', 'submit')); ?>
                        </div>

                        <?php $this->endWidget(); ?>
                    </div><!-- form -->

                <?php endif; ?>
            </div>
        </div>
    </body>
</html>
